using System;
using System.ComponentModel;
using System.Web.UI;
namespace JQueryControlToolkit.Controls
{
    public class TagExtender : JQueryExtender
    {
        [JQueryElement("separator", false)]
        public string Separator
        {
            get
            {
                return base.GetPropertyValue<string>("Separator", ",");
            }
            set
            {
                base.SetPropertyValue<string>("Separator", value);
            }
        }
        [JQueryElement("autocompleteValidates")]
        public bool Validates
        {
            get
            {
                return base.GetPropertyValue<bool>("Validates", true);
            }
            set
            {
                base.SetPropertyValue<bool>("Validates", value);
            }
        }
        [JQueryElement("limit")]
        public int? Limit
        {
            get
            {
                return base.GetPropertyValue<int?>("Limit", null);
            }
            set
            {
                base.SetPropertyValue<int?>("Limit", value);
            }
        }
        [JQueryEvent("resolve"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public JSFunctionString OnResolve
        {
            get
            {
                return base.GetPropertyValue<JSFunctionString>("OnResolve", null);
            }
            set
            {
                base.SetPropertyValue<JSFunctionString>("OnResolve", value);
            }
        }
        [JQueryEvent("resolve"), DefaultValue(null)]
        public JSObject OnResolveObject
        {
            get
            {
                return base.GetPropertyValue<JSObject>("OnResolveObject", null);
            }
            set
            {
                base.SetPropertyValue<JSObject>("OnResolveObject", value);
            }
        }
        [JQueryElement("autocomplete"), DefaultValue(null), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public AutocompleteExtender Autocomplete
        {
            get
            {
                return base.GetPropertyValue<AutocompleteExtender>("Autocomplete", null);
            }
            set
            {
                base.SetPropertyValue<AutocompleteExtender>("Autocomplete", value);
            }
        }

        [JQueryEvent("add")]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public JSFunctionString OnAdd
        {
            get
            {
                var value = GetPropertyValue<JSFunctionString>("OnAdd", null);
                if (value == null)
                    SetPropertyValue("OnAdd", value = new JSFunctionString());
                return value;
            }
            set { SetPropertyValue("OnAdd", value); }
        }
        [JQueryEvent("remove")]
        [PersistenceMode(PersistenceMode.InnerProperty)]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public JSFunctionString OnRemove
        {
            get
            {
                var value = GetPropertyValue<JSFunctionString>("OnRemove", null);
                if (value == null)
                    SetPropertyValue("OnRemove", value = new JSFunctionString());
                return value;
            }
            set { SetPropertyValue("OnRemove", value); }
        }



        protected override string jQueryFunction
        {
            get
            {
                return "tag";
            }
        }
        public override void DataBind()
        {
            base.DataBind();
            if (this.Autocomplete != null)
            {
                this.Autocomplete.DataBind();
            }
        }
    }
}
